//
//  UserManager.m
//  XingXue
//
//  Created by XingXue on 2023.
//  Copyright © 2023 XingXue. All rights reserved.
//

#import "UserManager.h"

@implementation UserManager

+ (instancetype)shareInstance {
    static UserManager *_MCUserManager = nil;
    static dispatch_once_t oncePredicate;
    dispatch_once(&oncePredicate, ^{
        _MCUserManager = [[self alloc] init];
    });
    return _MCUserManager;
}

- (void)saveUserData:(UserManager *)userManager {
    NSDictionary *dic = userManager.mj_keyValues;
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setObject:dic forKey:@"XingXue"];
    [userDefaults synchronize];
}

- (UserManager *)userManager {
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSDictionary *dic = [userDefaults objectForKey:@"XingXue"];
    UserManager *userManager = [UserManager mj_objectWithKeyValues:dic];
    if (!userManager) {
        userManager = [UserManager new];
    }
    if (kIsCeShi > 0) {
        userManager.isSubscribe = YES;
    }
    return userManager;
}

@end
